/**
 * @author sce
 * @description 增加get方法的参数获取
 */

import { BaseContext } from 'koa';

export default (routerPrefix: string) => {
    return async (ctx: BaseContext, next: any) => {
        if (ctx.url.startsWith(routerPrefix)) {
            ctx.request.body = { ...ctx.request.body, ...ctx.request.query };
            ctx.parameter = { ...ctx.request.body, ...ctx.request.query };
        }
        await next();
    };
};